package accounting.trade.model.dao;

import java.sql.SQLException;
import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import accounting.trade.model.vo.ItemVO;
import accounting.trade.model.vo.ProductVO;
import accounting.trade.model.vo.TradeVO;
import accounting.trade.model.vo.WarehouseItemVO;


public class TradeDaoImpl extends SqlMapClientDaoSupport implements TradeDao{

	@Override
	public void insert_trade_info(TradeVO vo) throws SQLException {
		//System.out.println(vo.toString());
		this.getSqlMapClient().insert("trade.insert_trade_info",vo);
	}
	@Override
	public void stockinput(double c_stock) throws SQLException {
		this.getSqlMapClient().insert("trade.stockinput",c_stock);
	}
	@Override
	public Object getstock() throws SQLException {
		return this.getSqlMapClient().queryForObject("trade.getstock");
	}
	@Override
	public List getTradeInfo(int page) throws SQLException {
		//System.out.println(vo.toString());
		return this.getSqlMapClient().queryForList("trade.getTradeInfo",page);
	}
	@Override
	public Object getItemPrice(int item_code) throws SQLException {
		//System.out.println(vo.toString());
		return this.getSqlMapClient().queryForObject("trade.getItemPrice",item_code);
	}
	public Object getOpeningBlance() throws SQLException {
		//System.out.println(vo.toString());
		return this.getSqlMapClient().queryForObject("trade.getOpeningBlance");
	}
	public void updateBlance(double blance) throws SQLException {
		//System.out.println(vo.toString());
		this.getSqlMapClient().update("trade.updateBlance",blance);
	}
	@Override
	public Object countinfo() throws SQLException {
		//System.out.println(vo.toString());
		return this.getSqlMapClient().queryForObject("trade.countinfo");
	}
	@Override
	public Object index_seq() throws SQLException {
		//System.out.println(vo.toString());
		return this.getSqlMapClient().queryForObject("trade.index_seq");
	}
	@Override
	public Object product_seq() throws SQLException {
		//System.out.println(vo.toString());
		return this.getSqlMapClient().queryForObject("trade.product_seq");
	}
	@Override
	public Object wareitem_seq() throws SQLException {
		//System.out.println(vo.toString());
		return this.getSqlMapClient().queryForObject("trade.wareitem_seq");
	}
	@Override
	public void selectwareitem(TradeVO vo) throws SQLException {
		//System.out.println(vo.toString());
		this.getSqlMapClient().insert("trade.insert_warehouseitem",vo);
	}
	@Override
	public void insert_warehouseitem(TradeVO vo) throws SQLException {
		//System.out.println(vo.toString());
		this.getSqlMapClient().insert("trade.insert_warehouseitem",vo);
	}
	@Override
	public void delete_warehouseitem(int wareitem_code) throws SQLException {
		//System.out.println(vo.toString());
		this.getSqlMapClient().delete("trade.delete_warehouseitem",wareitem_code);
	}
	@Override
	public void update_warehouseitem(TradeVO vo) throws SQLException {
		//System.out.println(vo.toString());
		this.getSqlMapClient().update("trade.update_warehouseitem",vo);
	}
	@Override
	public void insert_producttrade_buy(ProductVO vo) throws SQLException {
		System.out.println(vo);
		this.getSqlMapClient().insert("trade.insert_producttradebuy",vo);
	}
	@Override
	public void insert_producttrade_sell(ProductVO vo) throws SQLException {
		this.getSqlMapClient().insert("trade.insert_producttradesell",vo);
	}
	
	@Override
	public List customerlistvalue(String value) throws SQLException {
		//System.out.println(vo.toString());
		int CUS_CODE=Integer.parseInt(value);
		System.out.println(CUS_CODE);
		return this.getSqlMapClient().queryForList("trade.customerlistvalue",CUS_CODE);
	}
	@Override
	public List customerlist() throws SQLException {
		//System.out.println(vo.toString());
		return this.getSqlMapClient().queryForList("trade.customerlist");
	}
	@Override
	public List warehouselist() throws SQLException {
		//System.out.println(vo.toString());
		return this.getSqlMapClient().queryForList("trade.warehouselist");
	}
	@Override
	public List warehouselistvalue(String value) throws SQLException {
		//System.out.println(vo.toString());
		int warehouse_code=Integer.parseInt(value);
		return this.getSqlMapClient().queryForList("trade.warehouselistvalue",warehouse_code);
	}
	@Override
	public List itemlist() throws SQLException {
		//System.out.println(vo.toString());
		return this.getSqlMapClient().queryForList("trade.itemlist");
	}
	@Override
	public List itemlistvalue(String value) throws SQLException {
		//System.out.println(vo.toString());
		int item_code=Integer.parseInt(value);
		return this.getSqlMapClient().queryForList("trade.itemlistvalue",item_code);
	}
	@Override
	public WarehouseItemVO getwareitem(int ware,int item) throws SQLException {
		WarehouseItemVO vo=new WarehouseItemVO();
		vo.setWarehouse_code(ware);
		vo.setItem_code(item);
		Object obj=this.getSqlMapClient().queryForObject("trade.getwareitem",vo);
		WarehouseItemVO vo1=(WarehouseItemVO)obj;
		return vo1;
	}
	@Override
	public Object checkBlance(int item_code) throws SQLException {
		return getSqlMapClient().queryForObject("trade.checkBlance",item_code);
	}
	@Override
	public List getBuyInfo(String time) throws SQLException {
		return getSqlMapClient().queryForList("trade.getBuyInfo",time);
	}
	@Override
	public List getSellInfo(String time) throws SQLException {
		return getSqlMapClient().queryForList("trade.getSellInfo",time);
	}
}
